package app

import (
	"kvmc/pkg/kvm"
)

type StartOption struct {
	ClusterName string
	Name        string
	All         bool
}

func (m *Manager) Start(option *StartOption) {
	nodes := m.GetClusterNodes(option.ClusterName)
	kvmNodes := make([]*kvm.Node, 0, len(nodes))
	if option.All {
		_ = m.RefreshStatus(nodes)
	}
	for _, node := range nodes {
		if option.All && node.IsRunning() || node.Name == option.Name {
			kvmNodes = append(kvmNodes, &kvm.Node{
				Hostname: node.Hostname,
				IP:       node.IP,
			})
		}
	}
	k := kvm.NewKvm(kvmNodes)
	k.Start()
}
